This math function is a bit different from others in the fact that it handles strings and returns a number. In fact, the scan( String, Format) function returns a double precision number as extracted from string String and according to string format Format. The format is built with the same rules sscanf uses. See man pages on scanf(3). Note that the format must contain one active "%lf". An example might be of some help here, especially to show how to use scan in conjunction with C-calculator mode defined strings. scan is particularly helpful to extract numbers from filenames. Recall that strings are defined by double quotes as in standard C.
At this point, it might be useful for you to know the "%[ ]" scanf construction. Let's go through some examples: "%*[a-zA-Z]" means to ignore the longest string matched so that it is composed of any letter; "%*[ˆ 0-9]" means to ignore the longest string matched so that it is NOT composed of any digit; "%*[ˆ _.]" means to ignore the longest string matched so that it is not composed of characters `_' or `.'.
# define a string called Testname let Testname = "dummy25.dat" # let y be the Neperian log of the number contained in that string let y = ln(scan(Testname, "%*[^0-9]%lf.dat")) # The following reads a number from stdin let input = scan(Read(), "%lf")
$, strings, C, cmode, quotes